package com.qf.day06;

/**
 * 动物类，作为一个父类
 * 存在公共的属性和方法
 */
public class Animal {
    private  String name;
    private  String type;
    private String sex;
    private int age;
    private int hungr=10;

    public Animal() {
    }

    public Animal(String name, String type, String sex, int age) {
        this.name = name;
        this.type = type;
        this.sex = sex;
        this.age = age;
    }
    //实例方法一半写在构造方法后面
    public void eat(){
        System.out.println(name+"在吃饭");
        this.hungr=this.hungr-1;
    }


    //一般SET GET放到类的最后
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public int getHungry() {
        return hungr;
    }

    public void setHungry(int hungry) {
        this.hungr = hungr;
    }

    @Override
    public String toString() {
        return "Animal{" +
                "name='" + name + '\'' +
                ", type='" + type + '\'' +
                ", sex='" + sex + '\'' +
                ", age=" + age +
                ", hungr=" + hungr +
                '}';
    }

}
